<?php

class Act extends CI_Controller {

    function __Construct() {
        parent::__Construct();
        $this->load->database();
        $this->load->helper('url', 'form');
    }

    function index() {
        //redirect('act/other');
    }

    function other() {

        $this->load->model('chat_topic_m');
        $this->load->library('form_validation');

        $this->form_validation->set_rules('other_title', 'Title', 'trim|required');
        $this->form_validation->set_rules('other_body', 'Content', 'trim|required');

        if ($this->form_validation->run() == FALSE) {
            $data['title'] = "Leave your idea";
            $this->load->view('other', $data);
        } else {
            $authorID = $this->chat_topic_m->getAuthorID($this->session->userdata('user_login'));
            $added['add'] = $this->chat_topic_m->add_other($authorID);
            if ($added) {
                redirect('act/thank_you');
            } else {
                echo "Error";
            }
        }
    }

    function activity() {
        $data['title'] = "Your activities";
        $this->load->model('activity_m');
        $data['your_post'] = $this->activity_m->all_user_post();
        $data['your_reply'] = $this->activity_m->all_user_reply();
        $data['author_id'] = $this->activity_m->getAuthorID($this->session->userdata('user_login'));

        $this->load->view('activity', $data);
    }

    function post_detail() {
        $data['title'] = "Your post detail!";
        $id = $this->uri->segment(3);
        $this->load->model('activity_m');
        $data['post_detail'] = $this->activity_m->post_detail();
        //$data['author_id'] = $this->activity_m->getAuthorID($this->session->userdata('user_login'));
        //$this->db->where('ID', $id);

        $this->load->view('activity_detail', $data);
    }

    function reply_detail() {
        $data['title'] = "Your replied detail!";
        $id = $this->uri->segment(3);
        $this->load->model('activity_m');
        $data['reply_detail'] = $this->activity_m->reply_detail();


        $this->load->view('reply_detail', $data);
    }

    //thanks u page
    function thank_you() {
        $data['title'] = "Thank you!";

        $this->load->view('thank_you', $data);
    }

}

?>